<script>
    /**
     * 短信验证
     * @type {{sendVerify: Function, verify: Function}}
     */
    module.exports = {
        /**
         * 发送验证短信
         */
        sendSmsVerify:_.throttle(function(phoneNum,callback){
            if (typeof callback != 'function'){
                var callback = function(ret,message){
                    alert(message);
                }
            }

            axios.post('/ajax/auth/smsverify', {
                phoneNum: phoneNum
            }).then(function (response) {
                if (response.data.code == 200) {
                    callback(true,'发送成功');
                } else {
                    callback(false,response.data.message || '发送失败，请稍后再试');
                    alert(response.data.message || '发送失败，请稍后再试');
                }
            },function (response) {
                callback(false,response.data.message || '发送失败，请稍后再试')
            }).catch(function (err) {
                callback('发送失败，请稍后再试')
            });
        },500),
        /**
         * 校验短信验证码
         */
        smsVerify:_.throttle(function(phoneNum,verifyCode,callback){
            if (typeof callback != 'function'){
                var callback = function(ret,message){
                    alert(message);
                }
            }

            axios.post('/ajax/auth/smsverify', {
                phoneNum:phoneNum,
                verifyCode:verifyCode,
            }).then(function (response) {
                if (response.data.code == 200) {
                    callback(true,'验证成功');
                } else {
                    callback(false,response.data.message || '验证失败');
                }
            }).catch(function (err) {
                callback(false,'验证失败');
            });
        },200)
    };
</script>